using System;
using System.Collections.Generic;
using System.Text;
using AAM.DAL;
using CMS.BIZ;
using AAM.BIZ;
using AAM.SQL;

namespace CMS.BOP
{
    public class SqlBizForumPostProvider : SqlBizObjectProvider<BizForumPost>
    {

        public BizForumPost Read(int forumPostID) { return Read(new ObjectID(BizForumPost.ObjectType, new object[] { forumPostID })); }
        public BizForumPost Find(int forumPostID) { return Find(new ObjectID(BizForumPost.ObjectType, new object[] { forumPostID })); }
        public bool Delete(int forumPostID) { return Delete(new ObjectID(BizForumPost.ObjectType, new object[] { forumPostID })); }

        public List<BizForumPost> ReadAllByForum(int? forumID, string order)
        {
            Command command;
            string orderBy = " ORDER BY " + order;
            if (forumID == null) command = Connection.CreateCommand("SELECT * FROM " + Table.TableName + " WHERE ForumID IS NULL" + orderBy);
            else
            {
                command = Connection.CreateCommand("SELECT * FROM " + Table.TableName + " WHERE ForumID=?" + orderBy);
                command.AddParameter(forumID);
            }
            return CreateListFromCommand(command);
        }
        public List<BizForumPost> ReadAllByForum(int? forumID) { return ReadAllByForum(forumID, "CreationDate"); }

    }
}
